package ninja9.muzik.dao;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Playlist entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "playlist", catalog = "muzik")
public class Playlist implements java.io.Serializable {

	// Fields

	private Integer id;
	private User user;
	private String name;
	private Set<PlaylistItem> playlistItems = new HashSet<PlaylistItem>(0);

	// Constructors

	/** default constructor */
	public Playlist() {
	}

	/** minimal constructor */
	public Playlist(User user, String name) {
		this.user = user;
		this.name = name;
	}

	/** full constructor */
	public Playlist(User user, String name, Set<PlaylistItem> playlistItems) {
		this.user = user;
		this.name = name;
		this.playlistItems = playlistItems;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id", nullable = false)
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "name", nullable = false, length = 65535)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "playlist")
	public Set<PlaylistItem> getPlaylistItems() {
		return this.playlistItems;
	}

	public void setPlaylistItems(Set<PlaylistItem> playlistItems) {
		this.playlistItems = playlistItems;
	}

}